package com.xm.zcf.action.user;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.xm.zcf.domain.category.Category;
import com.xm.zcf.domain.product.Product;
import com.xm.zcf.service.product.ProductService;
import com.xm.zcf.util.PageBean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2017/3/27.
 */
@Controller
@Scope("prototype")
public class UserProductAction extends ActionSupport implements ModelDriven<Product>{
    private Product model=new Product();
    private Integer page;
    private Integer limit=12;
    private Integer cid;
    private Integer id;
    private Integer csid;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getCsid() {
        return csid;
    }

    public void setCsid(Integer csid) {
        this.csid = csid;
    }

    public Integer getCid() {
        return cid;
    }

    public void setCid(Integer cid) {
        this.cid = cid;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    @Resource
    private ProductService productService;

    public String findByCid(){
        PageBean<Product> pageBean=productService.findPageBean(page,limit,cid);
        ActionContext.getContext().getValueStack().push(pageBean);
        return "findByCid";
    }
    public String findByCsid(){
        PageBean<Product> pageBean=productService.findCsPageBean(page,limit,csid);
        ActionContext.getContext().getValueStack().push(pageBean);
        return "findByCsid";
    }
    public String findByPid(){
        Product pageBean=productService.findByPid(id);
        ActionContext.getContext().getValueStack().push(pageBean);
        return "findByPid";
    }
    @Override
    public Product getModel() {
        return model;
    }
}
